
/*

    event.target.style.color="#FFFFFF"
    event.target.style.cursor="pointer"


    event.target.style.color="#CCCCCC"
*/
let managerLoginNumber = document.getElementById("managerLoginNumberAndName")

managerLoginNumber.addEventListener("click", (event) => {
    document.location = "./home.html"

})
managerLoginNumber.addEventListener("mouseenter", (event) => {
    event.target.style.color = "#FFFFFF"
    event.target.style.cursor = "pointer"
})
managerLoginNumber.addEventListener("mouseleave", (event) => {
    event.target.style.color = "#CCCCCC"

})

let managerLoginSubmit = document.getElementById("managerLoginSubmit")

let checkManagerIDAndPassword = function (id,pwd) {
return true;

}
managerLoginSubmit.addEventListener("click",()=>{
    let managerID = document.getElementById("managerID").value
    let managerPassword = document.getElementById("managerPassword").value
    console.log(managerID+managerPassword)
    if(checkManagerIDAndPassword()) {
        $.post("/pub/managerLogin",
            {

                id:managerID,
                password:managerPassword

            },
            function(res){
            if(res.status.startsWith("4")) {
                document.getElementById("loginInformation").innerText=res.message
            }
            else {
                Cookies.set('id', res.data.id, { expires: 1 })
                Cookies.set('username', res.data.username, { expires: 1 })
                alert(`sign in success,${Cookies.get('username')}`)
                document.location="/public/html/ManagerDashboard.html"
            }
            },"json");
    }
    else {
        document.getElementById("loginInformation").innerText="user ID or password invalid"
    }


})
